package edzis.translatebuddy.control.command
{
	import com.yahoo.astra.fl.controls.TabBar;
	import edzis.translatebuddy.ApplicationFacade;
	import edzis.translatebuddy.TranslateBuddy;
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.command.SimpleCommand;
	import edzis.translatebuddy.model.*;
	import edzis.translatebuddy.view.components.*;
	import edzis.translatebuddy.view.*;
	
	public class SelectSession extends SimpleCommand implements ICommand
	{
		
		override public function execute(notification:INotification):void
		{
			
			
			var app:TranslateBuddy = notification.getBody() as TranslateBuddy;
			
			var appRroxy:AppProxy = facade.retrieveProxy(AppProxy.NAME) as AppProxy;
			
			var tabBar:TabBar = new TabBar();
			tabBar.dataProvider = appRroxy.navData;
			facade.registerMediator(new NavigationMediator(tabBar));
			app.addChild(tabBar);
			
			var choseSession:ChoseSession = new ChoseSession();
			app.addChild(choseSession);
			choseSession.x = 22;
			choseSession.y = 42;
			facade.registerMediator(new ChoseSessionMediator(choseSession));
			
			var addWord:AddWord = new AddWord();
			app.addChild(addWord);
			addWord.x = 22;
			addWord.y = 42;
			facade.registerMediator(new AddWordMediator(addWord));
			
			var translateWord:TranslateWord = new TranslateWord();
			app.addChild(translateWord);
			translateWord.x = 22;
			translateWord.y = 42;
			facade.registerMediator(new TranslateWordMediator(translateWord));
			
			var watchWords:WatchWords = new WatchWords();
			app.addChild(watchWords);
			watchWords.x = 22;
			watchWords.y = 42;
			facade.registerMediator(new WatchWordsMediator(watchWords));


			
			// Send first Notification here...
			//sendNotification(ApplicationFacade.SOME_NOTIFICATION);
			ArthropodDebug.log("appRroxy.appState " + appRroxy.appState);
			appRroxy.appState = AppProxy.CHOSE_SESSION;
			(facade.retrieveProxy(DataProxy.NAME) as DataProxy).connectToDb();
		
		}
		
	}
}